package com.weibiao.zhuhai.concurrent.syncronized;

public class DeadLockDemo {
	private static Object lockA = new Object();
	private static Object lockB = new Object();
	private static void startThreadA(){
		new Thread(){
			@Override
			public void run() {
				synchronized (lockA) {
					try {
						Thread.sleep(1000);
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
					synchronized (lockB) {
						
					}
				}
			}
		}.start();
	}
	private static void startThreadB(){
		new Thread(){
			@Override
			public void run() {
				synchronized (lockB) {
					try {
						Thread.sleep(1000);
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
					synchronized (lockA) {
						
					}
				}
			}
		}.start();
	}
	
	public static void main(String[] args) {
		startThreadA();
		startThreadB();
	}
}
